<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">

<head>
    <th:block th:include="include :: header('站点设置')" />
    <th:block th:include="include::bootstrap-select-css" />
</head>

<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <div class="tabs-container">
            <ul class="nav nav-tabs" id="config-title">
                <li class="active"><a data-toggle="tab" href="#theme" aria-expanded="true">主题设置</a>
                </li>
            </ul>
            <div class="tab-content" th:with="themeConfig=${@configTag.getConfigValueMap('themeConfig')}">
                <!-- 主题 -->
                <div class="tab-pane active" id="theme">
                    <form class="form-horizontal m" id="form-theme">
                        <div class="form-group">
                            <label class="col-sm-3 control-label is-">默认主题：</label>
                            <div class="col-sm-8">
                                <input name="oly.theme.used" class="disabled form-control" disabled
                                    th:value="${themeConfig['oly.theme.used']}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label is-">多主题：</label>
                            <div class="col-sm-8">
                                <label class="toggle-switch switch-solid">
                                    <input type="checkbox" id="oly.theme.more"
                                        th:checked="${themeConfig['oly.theme.more']}">
                                    <input type="hidden" name="oly.theme.more"
                                        th:value="${themeConfig['oly.theme.more']}" />
                                    <span></span>
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label is-">主题配置：</label>
                            <div class="col-sm-8">
                                <label class="toggle-switch switch-solid">
                                    <input type="checkbox" id="oly.theme.setting"
                                        th:checked="${themeConfig['oly.theme.setting']}">
                                    <input type="hidden" name="oly.theme.setting"
                                        th:value="${themeConfig['oly.theme.setting']}" />
                                    <span></span>
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label is-">重建所有索引：</label>
                            <div class="col-sm-8">
                                <div class="input-group">
                                    <button type="button" class="btn btn-primary"
                                        onclick="buildAllArticleIndex()">重建索引</button>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <br>
        <button type="button" class="btn btn-w-m btn-primary center-block" id="submit-btn">修改</button>
    </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include::bootstrap-select-js" />
    <script type="text/javascript">
        var prefix = ctx + "cms/theme";
        var myForm = "form-theme";
        $('#config-title a').click(function (e) {
            e.preventDefault();
            $(this).tab('show');
            myForm = $(this).attr('href').replace("#", "form-");
            console.log(myForm);
        });
        function setOpen() {
            $("input[name='oly.theme.more']").val($("input[id='oly.theme.more']").is(':checked'));
            $("input[name='oly.theme.setting']").val($("input[id='oly.theme.setting']").is(':checked'));
        }
        function submitHandler() {
            setOpen();
            var data = $("#" + myForm).serializeArray();
            data.push({ "name": "configGroup", "value": "themeConfig" });
            $.operate.saveModal(prefix + "/updateByGk", data);

        }
        $("#submit-btn").click(function () {
            submitHandler();
        })

        function buildAllArticleIndex() {
            $.operate.saveModal(ctx + "cms/theme/buildAllArticleIndex" );
        }
    </script>
</body>

</html>